function format(num) {
  let right = String(num).split(".")[1]

  let left = String(num).split(".")[0]
  let numYu = +left % 3
  let cishu = (left.length - numYu) / 3

  let str = ""
  if (numYu == 0) {
    for (let i = 0; i < cishu; i++) {
      if (i == 0) {
        str = str + left.slice(3 * i + numYu, 3 * (i + 1) + numYu)
      } else {
        str = str + "," + left.slice(3 * i + numYu, 3 * (i + 1) + numYu)
      }
    }
  } else {
    str = left.slice(0, numYu)
    for (let i = 0; i < cishu; i++) {
      str = str + "," + left.slice(3 * i + numYu, 3 * (i + 1) + numYu)
    }
  }

  return `${str}.${right}`
}

console.log(format(122323232323323.33))
